<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var s1="abcaaadef";
			var index = s1.indexOf("b",0);
			document.write("<br />找到的字符串位置为"+index);
			s1 = s1.replace("a","g");
			s1 = s1.replace(/a/gi,"g");//正则表达式，g=全局，i=不区分大小写。 
			document.write("<br />"+s1);
			
			var s2 = s1.substr(2,4);//(开始下标，截取长度)；
			document.write("<br />截取的长度为："+s2);
		</script>
	</body>
</html>
